Skip to content

feat: configurable max gas fee with message deferral#456

Merged
hannahhoward merged 4 commits intomainfrom
feat/max-gas-fee
Mar 20, 2026
Merged

feat: configurable max gas fee with message deferral#456
hannahhoward merged 4 commits intomainfrom
feat/max-gas-fee

Conversation

@hannahhoward
Copy link
Copy Markdown
Member

Summary

  • Adds per-message-type gas fee limits that defer on-chain message submission when estimated fees exceed the configured maximum
  • Deferred messages are retried automatically when fees drop, without consuming the task's retry budget
  • Gas limits are runtime-configurable via dynamic config (admin API or TOML) without node restart

Closes #455

Deliverables

File Status Summary
pkg/config/defaults.go Modified Added 6 gas config key constants (per-type limits + default + retry wait)
pkg/pdp/scheduler/handler.go Modified Added ErrGasTooHigh sentinel error; handler requeues without incrementing retries
pkg/pdp/tasks/sender_eth.go Modified Gas check before nonce lock in Do(); RetryWait in TypeDetails(); registry wiring
pkg/fx/scheduler/messages.go Modified Wired *dynamic.Registry into SenderETHParams
pkg/pdp/tasks/sender_eth_gas_test.go New 10 tests for gas check logic, config, fallback
pkg/pdp/scheduler/engine_gas_test.go New 3 tests for handler deferral behavior

Test plan

  • All acceptance tests pass (13/13)
  • All existing tests pass (no regressions)
  • Automated review passed (PASS verdict)

Generated with Claude Code

…estion

Add per-message-type gas fee limits that defer on-chain message submission
when estimated fees exceed the configured maximum. Deferred messages are
automatically retried when fees drop, without consuming retry budget.

Closes #455

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@hannahhoward hannahhoward marked this pull request as ready for review March 19, 2026 09:46
Copy link
Copy Markdown
Member

@alanshaw alanshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM but I think, as it stands, this will only allow dynamic configuration of the fees. To persist across restarts you'd need to add a Gas field to PDPServiceConfig.

I have opened an issue for documenting the max gas fee configuration #457

Comment thread pkg/config/defaults.go
Comment on lines +41 to +46
GasMaxFeeProve Key = "pdp.gas.max_fee.prove"
GasMaxFeeProvingPeriod Key = "pdp.gas.max_fee.proving_period"
GasMaxFeeProvingInit Key = "pdp.gas.max_fee.proving_init"
GasMaxFeeAddRoots Key = "pdp.gas.max_fee.add_roots"
GasMaxFeeDefault Key = "pdp.gas.max_fee.default"
GasRetryWait Key = "pdp.gas.retry_wait"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking and minor, but the max_fee namespace makes reading these vars very...yoda.

The suggestion below makes them a little closer to Lotus style (as was mentioned in the issue), which are IMHO a bit easier to read.

Suggested change
GasMaxFeeProve Key = "pdp.gas.max_fee.prove"
GasMaxFeeProvingPeriod Key = "pdp.gas.max_fee.proving_period"
GasMaxFeeProvingInit Key = "pdp.gas.max_fee.proving_init"
GasMaxFeeAddRoots Key = "pdp.gas.max_fee.add_roots"
GasMaxFeeDefault Key = "pdp.gas.max_fee.default"
GasRetryWait Key = "pdp.gas.retry_wait"
MaxProveGasFee Key = "pdp.gas.max_prove_fee"
MaxProvingPeriodGasFee Key = "pdp.gas.max_proving_period_fee"
MaxProvingInitGasFee Key = "pdp.gas.max_proving_init_fee"
MaxAddRootsGasFee Key = "pdp.gas.max_add_roots_fee"
DefaultMaxGasFee Key = "pdp.gas.default_max_fee"
GasTooHighRetryWait Key = "pdp.gas.too_high_retry_wait"

Comment thread pkg/pdp/tasks/sender_eth.go Outdated
config.GasMaxFeeProvingPeriod: {Value: uint(0), Schema: dynamic.UintSchema{Max: ^uint(0)}},
config.GasMaxFeeProvingInit: {Value: uint(0), Schema: dynamic.UintSchema{Max: ^uint(0)}},
config.GasMaxFeeAddRoots: {Value: uint(0), Schema: dynamic.UintSchema{Max: ^uint(0)}},
config.GasMaxFeeDefault: {Value: uint(0), Schema: dynamic.UintSchema{Max: ^uint(0)}},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should add a dynamic.FilCurrencyStringSchema that allows these values to be specified as a string with a "FIL" or "attoFIL" suffix e.g. "100 attoFIL".

hannahhoward and others added 3 commits March 20, 2026 00:04
Gas fee limits now persist across restarts via TOML config under [pdp.gas]:

  [pdp.gas]
  retry_wait = "5m"
  [pdp.gas.max_fee]
  prove = 50000000000000000
  add_roots = 10000000000000000

Static config values are used as initial values for the dynamic registry.
Runtime updates via admin API still work and override the static values.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds docs/content/configuration/pdp/gas.md covering:
- All 6 config keys with types, defaults, and env vars
- Message type descriptions and time sensitivity
- Operator recommendations (conservative/permissive/no limits)
- Runtime adjustment examples via admin CLI
- TOML configuration examples

Updates the Dynamic Configuration table in the config index
and adds the gas page to the PDP section nav.

Closes #457

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@hannahhoward hannahhoward merged commit 616abf7 into main Mar 20, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: configurable max gas fee with message deferral during high congestion

2 participants